<?php
    $change_logo = '';
    $li = '';
    if($company['Company']['logo'])
        $logo = $company['Company']['logo'];
    else
        $logo = '/files/company/logo/default.png';
    $span_logo = $this->Html->image($logo, array('alt' => $company['Company']['name'], 'title' => $company['Company']['name'], 'class' => 'logo'));

    if($company['Company']['user_id'] == $this->Bayon->userId()){
        
        $li .= $this->Html->tag('li', $this->Html->link(__('<span class="ui-icon ui-icon-pencil"></span>Change logo', true), '/company/change_logo/'.$company['Company']['id'], array('escape' => false)), array());
    }
    if($liked == false)
        $li .= $this->Html->tag('li', $this->Html->link(__('<span class="ui-icon ui-icon-heart"></span>Like', true), '#', array( 'escape' => false, 'title' => sprintf(__('Like %s', true), $company['Company']['name']))), array('id' => 'menu_like'));
    
    $li .= $this->Html->tag('li', $this->Html->link('<span class="ui-icon ui-icon-person"></span>'.ucfirst($company['User']['username']), '/'.$company['User']['username'], array('escape' => false)), array('title' => sprintf(__('Created by %s', true), $company['User']['username'])));
    $li .= $this->Html->tag('li', $this->Html->link(__('<span class="ui-icon ui-icon-circle-plus"></span>Create company', true), '/company/create_company', array( 'escape' => false)), array('id' => 'menu_create_company'));
    $ul = $this->Html->tag('ul', $li, array('id' => 'company_left_menu'));
    echo $this->Html->div('logo_wrap',$span_logo . $ul, array('id' => 'logo_wrap'));

    //javascript
    $this->Js->get('#menu_like');
    $this->Js->event('click', $this->Js->redirect(array('controller' => 'likes', 'action' => 'addLike',$company['Company']['id'], OBJECT_TYPE_COMPANY )));
    ?>
<script type="text/javascript">
    function likeThis(data){
        if(data['error'] == -1){
            alert(data['error']);
             <?php echo $this->Js->redirect('/login'); ?>
        }
       
    }
</script>

   

